import request from "@/utils/request"


/**
 * 获取所有设备
 */
export function getEquipment() {
  return request({
    url: '/equipment?action=',
    method: 'get'
  })
}


/**
 * 更加id查询设备详情
 * @param id 设备id
 * @returns {AxiosPromise}
 */
export function getEquipmentById(id) {
  return request({
    url: `/equipment/${id}?engineer_id=`,
    method: 'get'
  })
}

/**
 * 更加id查询设备详情
 * @param id 设备id
 * @returns {AxiosPromise}
 */
export function deleteEquipmentById(id) {
  return request({
    url: `/equipment/${id}`,
    method: 'delete'
  })
}

/**
 * 创建空设备
 * @returns {AxiosPromise}
 */
export function createEquipment() {
  return request({
    url: '/equipment/create',
    method: 'get'
  })
}

/**
 * 更新设备信息
 * @param editorID 设备id
 * @param data 设备更新信息
 * @returns {AxiosPromise}
 */
export function updateEquipment(editorID, data) {
  return request({
    url: '/equipment/' + editorID + '?' + data,
    method: 'put',
  })
}

/**
 * 获取设备类型
 * @returns {AxiosPromise}
 */
export function getEquipmentType() {
  return request({
    url: '/type',
    method: 'get',
  })
}

/**
 * 添加设备类型
 * @returns {AxiosPromise}
 */
export function createEquipmentType(type) {
  return request({
    url: '/type/create',
    method: 'get',
    params: {type:type}
  })
}

/**
 * 修改设备类型
 * @param id 类型id
 * @param newType 新的类型
 * @returns {AxiosPromise}
 */
export function updateEquipmentType(id,newType) {
  return request({
    url: `/type/${id}?type=${newType}`,
    method: 'put',
  })
}

/**
 * 删除设备类型
 * @param id 类型id
 * @returns {AxiosPromise}
 */
export function deleteEquipmentTypeById(id) {
  return request({
    url: '/type/'+id,
    method: 'delete',
  })
}






